/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package questiondetector;

import edu.uet.questiondetector.utils.TaggerTool;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.util.List;
import java.util.Scanner;
import java.util.logging.Level;
import java.util.logging.Logger;
import sentencesplit.SentenceSplit;

/**
 *
 * @author ThinhNK
 */
public class Utils {
    public static final String nonSpecial = "[^A-Za-z0-9 _ĐĂÂÊÔƠƯÁÀÃẠẢẤẦẪẬẨẮẰẴẶẲÉÈẼẸẺẾỀỄỆỂÒÓÕỌỎỐỒỖỘỔỜỚỠỢỞÙÚŨỤỦỪỨỮỰỬÝỲỸỴỶÍÌĨỊỈđăâêôơưáàãạảấầẫậẩắằẵặẳéèẽẹẻếềễệểòóõọỏốồỗộổờớỡợởùúũụủừứữựửýỳỹỵỷíìĩịỉ!\\?\\.]";        
    
    public static void main(String[] args){
        String s[] = TaggerTool.instance().tokenize("Mình nên chọn card Ati hay nVidia ?");
        String ta = TaggerTool.instance().tag("Mình nên chọn card Ati hay nVidia ?");
    }
    
    public static void splitSentenceFromFile(String inFile, String outFile){
        try {
            Scanner sc = new Scanner(new File(inFile));
            String s = null;
            File oFile = new File(outFile);
            FileWriter wr = new FileWriter(oFile);
            List<String> sens = null;
            int c = 0;
            while(sc.hasNext()){
                s = sc.nextLine();
                if(s.length() > 5){
                    sens = SentenceSplit.split(s);
                    for(String sen: sens){
                        if(sen.length() > 20){
                            c++;
                            sen = sen.replaceAll(nonSpecial, "");
                            wr.append(sen).append("\n");
                        }
                    }
                }else{
                    wr.append("X-X-X\n");
                }
            }
            wr.close();
            System.out.println(c);
        } catch (FileNotFoundException ex) {
            Logger.getLogger(Utils.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IOException ex) {
            Logger.getLogger(Utils.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}
